<template>
	<view class="paper-list u-f-ac animate__animated animate__fadeIn animate__fast"
	@tap="opendetail">
		<image 
		:src="item.userpic" 
		mode="widthFix" 
		lazy-load="">
		</image>
		
		<view>
			<view class="u-f-ac u-f-jsb">
				{{item.username}}
				<view>{{item.time}}</view>
			</view>
			<view class="u-f-ac u-f-jsb">
				{{item.data}}
				<template v-if="(item.noreadnum > 0)">
					<uni-badge :text="getItemNoreadnum" type="error" />
				</template>
			</view>
		</view>
	</view>
</template>

<script>
	import uniBadge from "../../components/uni-badge/uni-badge.vue";
	export default {
		props:{
			item: Object,
			index: Number
		},
		components:{
			uniBadge
		},
		computed: {
			getItemNoreadnum() {
				return this.item.noreadnum
			}
		},
		methods:{
			opendetail(){
				let obj = {
					userid:this.item.userid,
					username:this.item.username,
					userpic:this.item.userpic
				};
				this.User.navigate({
					url: '../../pages/user-chat/user-chat?userinfo='+JSON.stringify(obj),
				});
				// 更新未读数的状态
				this.$chat.Read(this.item)
			}
		}
	}
</script>

<style scoped>
	.paper-list{
		border-bottom: 1upx solid #EEEEEE;
		padding: 20upx 0;
	}
	.paper-list>image{
		width: 100upx;
		height: 100upx;
		border-radius: 100%;
		margin-right: 20upx;
		flex-shrink: 0;
	}
	.paper-list>view{
		flex: 1;
	}
	.paper-list>view>view:first-child{
		font-size: 36upx;
	}
	.paper-list>view>view:first-child>view{
		color: #CBCBCB;
	}
	.paper-list>view>view:last-child{
		color: #999999;
	}
</style>
